package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TransferAccountsVxBatchAddDTO;
import org.jsola.hr.dto.TransferAccountsVxBatchUpdateDTO;
import org.jsola.hr.entity.TransferAccountsVxBatchDO;
import org.jsola.hr.query.TransferAccountsVxBatchQuery;
import org.jsola.hr.service.ITransferAccountsVxBatchService;
import org.jsola.hr.vo.TransferAccountsVxBatchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账批次(微信)
 *
 * @author zhr
 */
@Component
public class TransferAccountsVxBatchTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsVxBatchService transferAccountsVxBatchService;

    /**
     * 生成add测试数据
     * @return TransferAccountsVxBatchAddDTO
     */
    public TransferAccountsVxBatchAddDTO getTransferAccountsVxBatchAddDTO(){
        TransferAccountsVxBatchAddDTO transferAccountsVxBatchAddDTO = new TransferAccountsVxBatchAddDTO();
        transferAccountsVxBatchAddDTO.setSpMchid(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setSubMchid(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setBatchId(getRandomValue("varchar",100));
        transferAccountsVxBatchAddDTO.setBatchStatus(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setBatchType(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setBatchName(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setBatchRemark(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setCloseReason(getRandomValue("varchar",64));
        transferAccountsVxBatchAddDTO.setTotalAmount(SafeKit.getInteger(getRandomValue("int",20)));
        transferAccountsVxBatchAddDTO.setTotalNum(SafeKit.getInteger(getRandomValue("int",10)));
        transferAccountsVxBatchAddDTO.setCreateTime(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setUpdateTime(getRandomValue("varchar",32));
        transferAccountsVxBatchAddDTO.setSuccessNum(SafeKit.getInteger(getRandomValue("int",10)));
        transferAccountsVxBatchAddDTO.setSuccessAmount(SafeKit.getInteger(getRandomValue("int",20)));
        transferAccountsVxBatchAddDTO.setFailNum(SafeKit.getInteger(getRandomValue("int",10)));
        transferAccountsVxBatchAddDTO.setFailAmount(SafeKit.getInteger(getRandomValue("int",20)));
        transferAccountsVxBatchAddDTO.setTransferPurpose(getRandomValue("varchar",16));
        return transferAccountsVxBatchAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsVxBatchUpdateDTO
     */
    public TransferAccountsVxBatchUpdateDTO getTransferAccountsVxBatchUpdateDTO(TransferAccountsVxBatchVO transferAccountsVxBatchVO){
        return transferAccountsVxBatchService.selectDOById(transferAccountsVxBatchVO.getId(), SITE_ID).to(TransferAccountsVxBatchUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsVxBatchQuery
     */
    public TransferAccountsVxBatchQuery getTransferAccountsVxBatchQuery() {
        TransferAccountsVxBatchQuery transferAccountsVxBatchQuery = new TransferAccountsVxBatchQuery();
        List<TransferAccountsVxBatchDO> transferAccountsVxBatchDOList = transferAccountsVxBatchService.list(new TransferAccountsVxBatchDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsVxBatchDOList)) {
            TransferAccountsVxBatchDO transferAccountsVxBatchDO = transferAccountsVxBatchDOList.get(0);
            transferAccountsVxBatchQuery = transferAccountsVxBatchDO.to(TransferAccountsVxBatchQuery.class);
        }
        return transferAccountsVxBatchQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsVxBatchVO
     */
    public TransferAccountsVxBatchVO saveTransferAccountsVxBatchExample(){
        TransferAccountsVxBatchAddDTO addDTO = this.getTransferAccountsVxBatchAddDTO();
        TransferAccountsVxBatchVO transferAccountsVxBatchVO = transferAccountsVxBatchService.save(addDTO,buildTokenUser());
        return transferAccountsVxBatchVO;
    }


}

